﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HU8.Helpers.Base
{
    public static class BaseHelper
    {
        public static string INSTALL_EXCEPTIONS = "/bin_temp/Ionic.Zip.dll,/bin/,/web.config,/Properties/,/obj/,/Content/Site/,/Templates/template/,/Installation/, /HU8.Web.Install.csproj,/HU8.Web.Install.csproj.user,/HU8.Web.Install.csproj.vspscc";
        //public static string UNINSTALL_EXCEPTIONS = "/bin/,/web.config,/Properties/,/obj/,/Content/Site/,/Templates/template/,/Installation/, /HU8.Web.Install.csproj,/HU8.Web.Install.csproj.user,/HU8.Web.Install.csproj.vspscc";
        /// <summary>
        /// 测试一个文件名或者文件夹名称是否在一个列表中
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="exceptionArray"></param>
        /// <returns></returns>
        public static bool IsNotInException(string fileName, string exceptions)
        {
            string[] exceptionArray = exceptions.Split(','); //例外
            fileName = fileName.Trim().ToLower();
            bool passed = true;
            if (exceptionArray.Length > 0 && exceptions.Trim() != "")
            {
                foreach (string ex in exceptionArray)
                {
                    string exc = ex.Trim().ToLower();
                    if (exc == fileName || (fileName.EndsWith("/") && fileName.StartsWith(exc)))
                    {
                        passed = false;
                    }
                }
            }
            return passed;
        }
    }
}
